<?php

// general page pieces:

function echoHeader(){
	echo "<html>\n";
	echo "<head>\n";
	echo "<title>\n";
	echo "..:: Lethal RO voting reward system ::..\n";
	echo "</title>\n";
	echo "</head>\n";
	echo "\n";
	echo "<body bgcolor=#EEEEFF>\n";
	echo "\n";
	echo "<table height=100% bgcolor=E0E0FF width=750 align=center border=0 cellpadding=0 cellspacing=0>\n";
	echo " <tr valign=valign='center'>\n";
	echo "  <td>\n";
}

function echoDisclaimer(){
	echo "<table bgcolor=#D0D0FF align=center width=100% border=0 cellpadding=1 cellspacing=0>\n";
	echo " <tr valign=top align=center>\n";
	echo "  <td>\n";
	echo "   \"Voting for Credits\" for <a href=http://lethalro.com target=_blank>Lethal RO</a> by <a href=http://jarinsoffice.com target=_blank>Jarin</a>, 2009. Version 1.5\n";
	echo "  </td>\n";
	echo " </tr>\n";
	echo "</table>\n";	
}

function echoFooter(){
	echo "  </td>\n";
	echo " </tr>\n";
	echo " <tr valign=bottom>\n";
	echo "  <td>\n";
	echoDisclaimer();
	echo "  </td>\n";
	echo " </tr>\n";	
	echo "</table>\n";
	echo "\n";
	echo "</body>\n";
	echo "</html>\n";
}


// index page pieces:

function echoLogin(){
	echo "<br>\n";
	echo "<form action='login.php' method='post'>\n";
	echo "<table align='center'>\n";
	echo " <tr align=center><td colspan=2>Please log in with your ingame credentials:<br></td></tr>\n";
	echo " <tr>\n";
	echo "  <td>ID</td>\n";
	echo "  <td><input type='text' name='id' size='10'></td>\n";
	echo " </tr>\n";
	echo " <tr>\n";
	echo "  <td>Pass</td>\n";
	echo "  <td><input type='password' name='password' size='10'></td>\n";
 	echo " </tr>\n";
	echo " <tr>\n";
	echo "  <td></td>\n";
	echo "  <td><input type='submit' name='submit' size='10' value='log in'></td>\n";
	echo " </tr>\n";
	echo "</table>\n";
	echo "</form>\n";
}

function echoVoting($votingSites){
	echo "<table align='center'>\n";
	echo " <tr>\n";
	echo "  <td>\n";
	$print = $_SESSION["USERNAME"];
	echo "   You are now logged on as <i>$print</i>\n";
	echo "  </td>\n";
	echo "  <td align='right'>\n";
	echo "   <a href=logout.php>log out</a>\n";
	echo "  </td>\n";
	echo " </tr>\n";
	echo " <tr colspan=2>\n";
	echo "  <td align='center'>\n";
	echo "   <br>You can vote for us on:\n";
	echo "  </td>\n";
	echo " </tr>\n";
	$noVotes = true;
	foreach ($votingSites as $site){
		$noVotes = false;
		echo " <tr colspan=2>\n";
		echo "  <td align='center'>\n";
		if(canVoteForSite($site["url"], $votingSites)){
			$url = $site["url"];
			$img = $site["img"];
			echo "   <br><a href=vote.php?vote=$url target=\"_blank\"><img src=$img>\n";
		}
		else{
			$name = $site["name"];
			$time = $site["time"];
			echo "   <br><b>$name</b> once every $time hours.\n";
		}
		echo "  </td>\n";
		echo " </tr>\n";
	}
	echo "</table>\n";
}
?>